package com.tally.server.dto;

import com.tally.server.enums.ResponseCodeEnum;

/**
 * @Author: sy
 * @Date: 2020/12/11 12:08
 * @Description:
 */
public class ResponseDTO<T> {
    private boolean success = true;

    private String code;

    private String message;

    private T content;

    public static <T> ResponseDTO success(T content){
        return new ResponseDTO<>("","",content);
    }

    public static <T> ResponseDTO fail(String msg){
        return new ResponseDTO<>(false,"",msg,null);
    }

    public static <T> ResponseDTO fail(ResponseCodeEnum responseCodeEnum){
        return new ResponseDTO<>(false,responseCodeEnum.getCode(),responseCodeEnum.getMsg(),null);
    }

    public ResponseDTO(String code,String message,T content){
        this.code = code;
        this.message = message;
        this.content = content;
    }

    public ResponseDTO(boolean success,String code,String message,T content){
        this.success = success;
        this.code = code;
        this.message = message;
        this.content = content;
    }

    public boolean isSuccess() {
        return success;
    }

    public void setSuccess(boolean success) {
        this.success = success;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getContent() {
        return content;
    }

    public void setContent(T content) {
        this.content = content;
    }
}
